﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.WmsManagement;
using Digitalmes.Model.FactoryManagement;
using Digitalmes.Model.ProductManagement;

namespace Digitalmes.Model.ProductManagement
{
    /// <summary>
    /// 产品
    /// </summary>
	[Table("Product")]

    [Display(Name = "_Model.Product")]
    public class Product : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._Product._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }

        [Display(Name = "_Model._LineShift._Line")]
        [Comment("产线")]
        public long? LineId { get; set; }

        public ProductionLine Line { get; set; }

        [Display(Name = "_Model._Product._Name")]
        [StringLength(200, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("产品名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Name { get; set; }

        [Display(Name = "_Model._Product._Code")]
        [StringLength(200, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("产品编码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Code { get; set; }

        [Display(Name = "_Model._Product._Material")]
        [Comment("物料")]
        public MaterialDoc Material { get; set; }
        [Display(Name = "_Model._Product._Material")]
        [Comment("物料")]
        public long? MaterialId { get; set; }


        [Display(Name = "_Model._Product._Active")]
        [Comment("激活")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool? Active { get; set; } = true;



        [Display(Name = "_Model._Product._ErpCode")]
        [Comment("Erp编号")]
        [NotMapped]
        public string ErpCode { get; set; }


        //[Display(Name = "_Model._ProductionLine._Product")]
        //[InverseProperty("Product")]
        //public List<ProductionLine> ProductionLine_Product { get; set; }


        [Display(Name = "_Model._ProductBom._Product")]
        [InverseProperty("Product")]
        public List<ProductBom> ProductBom_Product { get; set; }
        [Display(Name = "_Model._Product._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
